<!--_meta 作为公共模版分离出去-->
<?php $this->load->view('public/meta.html');?>
<!--/meta 作为公共模版分离出去-->

<link href="<?php echo base_url(),ADMIN_DIR?>/lib/webuploader/0.1.5/webuploader.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="page-container">
	<form action="<?php echo base_url();?>admin/goods/insert" method="post" name="theForm"  class="form form-horizontal" id="form-articl-add" enctype="multipart/form-data">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>商品名称：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text"  placeholder="" id="" name="goods_name">
			</div>
		</div>
		
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>商品分类：</label>
			<div class="formControls col-xs-8 col-sm-9"> <span class="select-box">
				<select name="cat_id" class="select">
					<option value="0">请选择...</option>
					<?php foreach($cates as $k=>$v) : ?>
					<option value="<?php echo $v['cat_id'];?>"><?php echo str_repeat('├',$v['level'])?>
							<?php echo $v['cat_name'];?></option>
					<?php endforeach;?>     
				</select>
				</span> </div>
		</div>

		<!--<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>商品品牌：</label>
			<div class="formControls col-xs-8 col-sm-9"> <span class="select-box">
				<select name="brand_id" class="select">
					<option value="0">请选择...</option>
					<?php foreach($brands as $k=>$v) : ?>
					<option value="<?php echo $v['brand_id'];?>"><?php echo $v['brand_name'];?></option>
					<?php endforeach;?>     
				</select>
				</span> </div>
		</div>-->

		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>本店售价：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" name="shop_price" id="" placeholder="" value="" class="input-text" style="width:90%">
				元</div>
		</div>
		
		

		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">市场售价：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" name="market_price" id="" placeholder="" value="" class="input-text" style="width:90%">
				元</div>
		</div>
		
		
		<div class="row cl" id="is_cuxiao">
			<label class="form-label col-xs-4 col-sm-2">是否促销：</label>
			<div class="formControls col-xs-8 col-sm-9 skin-minimal">
				<div class="radio-box" onclick="radioClicked(1)">
					<input type="radio" id="is_promote-1" value="1" name="is_promote"  onclick="radioClicked(1)">
					<label for="is_promote-1"  onclick="radioClicked(1)">促销</label>
				</div>
				
				<div class="radio-box"  onclick="radioClicked(0)">
					<input type="radio" id="is_promote-0" value="0" name="is_promote" checked="checked"  onclick="radioClicked(0)">
					<label for="is_promote-0"  onclick="radioClicked(0)">不促销</label>
				</div>



			</div>
		</div>

		<div class="row cl" style="display:none" id="promote_price">
			<label class="form-label col-xs-4 col-sm-2">促销价：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" name="promote_price" id="" placeholder="" value="" class="input-text" style="width:90%">
				元</div>
		</div>

		<div class="row cl" style="display:none" id="promote_start_time">
			<label class="form-label col-xs-4 col-sm-2">促销开始时间：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" onfocus="WdatePicker({minDate:'%y-%M-%d'})" id="logmin" class="input-text Wdate" style="width:180px;" name="promote_start_time">
			</div>
		</div>
		<div class="row cl" style="display:none" id="promote_end_time">
			<label class="form-label col-xs-4 col-sm-2">促销结束时间：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" onfocus="WdatePicker({minDate:'%y-%M-%d'})" id="logmax" class="input-text Wdate" style="width:180px;" name="promote_end_time">
			</div>
		</div>

		
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">商品图1：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<span class="btn-upload form-group">
					<input class="input-text upload-url" type="text" name="uploadfile" id="uploadfile" readonly nullmsg="请添加商品图1！" style="width:200px">
					<a href="javascript:void();" class="btn btn-primary radius upload-btn"><i class="Hui-iconfont">&#xe642;</i> 请添加商品图1</a>
					<input type="file" multiple name="image1" class="input-file">
				</span>
				<br/><br/>
				<span class="btn-upload form-group">
					<input class="input-text upload-url" type="text" name="uploadfile" id="uploadfile" readonly nullmsg="请添加商品图2！" style="width:200px">
					<a href="javascript:void();" class="btn btn-primary radius upload-btn"><i class="Hui-iconfont">&#xe642;</i> 请添加商品图2</a>
					<input type="file" multiple name="image2" class="input-file">
				</span>

				<br/><br/>
				<span class="btn-upload form-group">
					<input class="input-text upload-url" type="text" name="uploadfile" id="uploadfile" readonly nullmsg="请添加商品图3！" style="width:200px">
					<a href="javascript:void();" class="btn btn-primary radius upload-btn"><i class="Hui-iconfont">&#xe642;</i> 请添加商品图3</a>
					<input type="file" multiple name="image3" class="input-file">
				</span>

				<br/><br/>
				<span class="btn-upload form-group">
					<input class="input-text upload-url" type="text" name="uploadfile" id="uploadfile" readonly nullmsg="请添加商品图4！" style="width:200px">
					<a href="javascript:void();" class="btn btn-primary radius upload-btn"><i class="Hui-iconfont">&#xe642;</i> 请添加商品图4</a>
					<input type="file" multiple name="image4" class="input-file">
				</span>
			</div>
		</div>




		

		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">详细描述：</label>
			<div class="formControls col-xs-8 col-sm-9"> 
				<script id="editor" type="text/plain" style="width:100%;height:400px;"></script> 
			</div>
		</div>


		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">商品库存数量：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" name="goods_number" id="" placeholder="" class="input-text" style="width:90%">
			</div>
		</div>

		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">加入推荐：</label>
			<div class="formControls col-xs-8 col-sm-9 skin-minimal">
				<div class="check-box">
					<input type="checkbox" id="checkbox-j" value="1" name="is_best">
					<label for="checkbox-j">精品</label>
				</div>

				<div class="check-box">
					<input type="checkbox" id="checkbox-n"  value="1" name="is_new">
					<label for="checkbox-n">新品</label>
				</div>

				<div class="check-box">
					<input type="checkbox" id="checkbox-r" value="1" name="is_hot">
					<label for="checkbox-r">热销</label>
				</div>

			</div>
		</div>


		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">上架：</label>
			<div class="formControls col-xs-8 col-sm-9 skin-minimal">
				<div class="check-box">
					<input type="checkbox" id="checkbox-d" name="is_on_sale" value="1" checked="checked">
					<label for="checkbox-d">打勾表示允许销售，否则不允许销售。</label>
				</div>
			</div>
		</div>



		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">商品简单描述：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<textarea name="goods_brief" cols="" rows="" class="textarea"  placeholder="说点什么...最少输入10个字符" datatype="*10-100" dragonfly="true" nullmsg="备注不能为空！" onKeyUp="$.Huitextarealength(this,200)"></textarea>
				<p class="textarea-numberbar"><em class="textarea-length">0</em>/200</p>
			</div>
		</div>


		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>商品类型：</label>
			<div class="formControls col-xs-8 col-sm-9"> <span class="select-box">
				<select name="type_id" class="select"  id="switch_type">
					<option value="0">请选择商品类型</option>
					<?php foreach($goodstypes as $k=>$v) : ?>
					<option value="<?php echo $v['type_id']?>"><?php echo $v['type_name']?></option>
					<?php endforeach;?>     
				</select>
				</span> </div>
		</div>


		<div id="attrTable"></div>



		

		
		
		
		
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
				<button class="btn btn-primary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i> 保存并提交审核</button>
				
		</div>
	</form>
</div>

<!--_footer 作为公共模版分离出去-->
<?php $this->load->view('public/footer.html');?>
<!--/_footer /作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="<?php echo base_url(),ADMIN_DIR?>/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="<?php echo base_url(),ADMIN_DIR?>/lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
<script type="text/javascript" src="<?php echo base_url(),ADMIN_DIR?>/lib/jquery.validation/1.14.0/validate-methods.js"></script> 
<script type="text/javascript" src="<?php echo base_url(),ADMIN_DIR?>/lib/jquery.validation/1.14.0/messages_zh.js"></script> 
<script type="text/javascript" src="<?php echo base_url(),ADMIN_DIR?>/lib/webuploader/0.1.5/webuploader.min.js"></script> 
<script type="text/javascript" src="<?php echo base_url(),ADMIN_DIR?>/lib/ueditor/1.4.3/ueditor.config.js"></script>
<script type="text/javascript" src="<?php echo base_url(),ADMIN_DIR?>/lib/ueditor/1.4.3/ueditor.all.min.js"> </script>
<script type="text/javascript" src="<?php echo base_url(),ADMIN_DIR?>/lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">
/*var setting = {
	view: {
		dblClickExpand: false,
		showLine: false,
		selectedMulti: false
	},
	data: {
		simpleData: {
			enable:true,
			idKey: "id",
			pIdKey: "pId",
			rootPId: ""
		}
	},
	callback: {
		beforeClick: function(treeId, treeNode) {
			var zTree = $.fn.zTree.getZTreeObj("tree");
			if (treeNode.isParent) {
				zTree.expandNode(treeNode);
				return false;
			} else {
				demoIframe.attr("src",treeNode.file + ".html");
				return true;
			}
		}
	}
};*/

$(function(){
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
	
	
	
	

});



$(function(){
	var ue = UE.getEditor('editor',{

        'allowDivTransToP':false,
        'disabledTableInTable':true
        });
});

$(function(){
	//ajax动态获取商品属性
  	$("#switch_type").change(function(){
  		// alert(this.value);
  		var url ="<?php echo site_url('admin/goods/create_attrs_html');?>";
  		$.get(url,{'type_id':this.value},function(data){
  			$("#attrTable").html(data);
  		});
		
		
		
		
		
  	});
	
	
	
	/**
 * 点击类型按钮时切换选项的禁用状态
 */

	
	
	
	
})

function radioClicked(n)
{
  document.forms['theForm'].elements["promote_price"].disabled = n > 0 ? false : true;
  document.forms['theForm'].elements["promote_start_time"].disabled = n > 0 ? false : true;
  document.forms['theForm'].elements["promote_end_time"].disabled = n > 0 ? false : true;
  
  if($("#is_promote-0").checked){
		$("#promote_price").hide();
		$("#promote_start_time").hide();
		$("#promote_end_time").hide();
  }else{
	$("#promote_price").show();
	$("#promote_start_time").show();
	$("#promote_end_time").show();
  }
  
  
}



 
</script>
</body>
</html>